🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / feature / map / src / commonMain / kotlin / org / meshtastic / feature / map / MapNodePolicy.kt
Displaying Raw • Download
feature/map/src/commonMain/kotlin/org/meshtastic/feature/map/MapNodePolicy.kt renovate/fastlane-2.x-lockfile (056eed64) Text, 4.98 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.feature.map
Tff7b72import T7ee787org.meshtastic.core.model.Node
Tff7b72import T7ee787org.meshtastic.core.model.util.ONLINE_WINDOW_SECONDS
Tff7b72import T7ee787org.meshtastic.proto.Config
T8b949e/**
* Which nodes a map shows, and which of them draws on top.
*
* Renderer-independent on purpose. Both map engines answer these two questions, and until this existed each answered
* them separately — the Google map inline in `MapView`, the MapLibre map in its own module, which the Google flavour
* cannot even depend on. They had already drifted apart on the first question.
*/
Tff7b72object T56d364MapNodePolicy Tb4b4b4{
T8b949e/** Drawn above everything else: this node and favorites. */
Tff7b72const Tff7b72val Te6edf3PRIORITY_PROMINENT Tff7b72= T79c0ff5
T8b949e/** Everything else, with nothing to distinguish between them. */
Tff7b72const Tff7b72val Te6edf3PRIORITY_ORDINARY Tff7b72= T79c0ff4
T8b949e/**
* How far up the stack a node draws.
*
* The Google map turns this into a marker `zIndex` and the MapLibre map into a symbol sort key, but it is one
* product decision and it was previously written out as `5.0f`/`5.0f`/`4.0f` in one place and `5`/`4` in the other.
*/
Tff7b72fun Td2a8ffpriorityOfTb4b4b4(Te6edf3nodeTb4b4b4: Te6edf3NodeTb4b4b4, Te6edf3myNodeNumTb4b4b4: Tffa657Int?Tb4b4b4)Tb4b4b4: Tffa657Int Tff7b72=
Tff7b72if Tb4b4b4(Te6edf3nodeTb4b4b4.Te6edf3num Tff7b72=Tff7b72= Te6edf3myNodeNum Tff7b72|Tff7b72| Te6edf3nodeTb4b4b4.Te6edf3isFavoriteTb4b4b4) Te6edf3PRIORITY_PROMINENT Tff7b72else Te6edf3PRIORITY_ORDINARY
T8b949e/**
* Applies the map's filter chips to the node list.
*
* Pure so it can be tested without a renderer: the filter rules are the part users notice when they go wrong, and
* they should not need a GPU to verify.
*
* Your own node is exempt from both filters. You are always on your own map, whether or not you have favourited
* yourself and whether or not you have heard from yourself lately — the Google map has always done this, and the
* MapLibre map's own copy of these rules did not, so filtering to favourites there hid you from yourself.
*
* Nodes without a fix are dropped up front. They cannot be drawn, and leaving them in drags a camera that fits to
* these bounds toward (0, 0) — which is how the OSMdroid map used to open in the Atlantic.
*/
Tff7b72fun Td2a8ffvisibleNodesTb4b4b4(
Te6edf3nodesTb4b4b4: Te6edf3ListTff7b72<Te6edf3NodeTff7b72>Tb4b4b4,
Te6edf3filterStateTb4b4b4: Te6edf3BaseMapViewModelTb4b4b4.Te6edf3MapFilterStateTb4b4b4,
Te6edf3nowSecondsTb4b4b4: Tffa657LongTb4b4b4,
Te6edf3myNodeNumTb4b4b4: Tffa657Int?Tb4b4b4,
Tb4b4b4)Tb4b4b4: Te6edf3ListTff7b72<Te6edf3NodeTff7b72> Tff7b72= Te6edf3nodesTb4b4b4.Te6edf3filter Tb4b4b4{ Te6edf3node Tff7b72-Tff7b72>
Te6edf3nodeTb4b4b4.Te6edf3validPosition Tff7b72!Tff7b72= Tff7b72null Tff7b72&Tff7b72& Tb4b4b4(Te6edf3nodeTb4b4b4.Te6edf3num Tff7b72=Tff7b72= Te6edf3myNodeNum Tff7b72|Tff7b72| Te6edf3nodeTb4b4b4.Te6edf3passesFiltersTb4b4b4(Te6edf3filterStateTb4b4b4, Te6edf3nowSecondsTb4b4b4)Tb4b4b4)
Tb4b4b4}
T8b949e/**
* One node against every filter.
*
* The node-level rules match the node list's query exactly, because they carry its labels: direct means `hopsAway
* == 0` — a node whose distance was never measured (-1) is not direct — and unknown means a node that has not sent
* a short name.
*
* [BaseMapViewModel.MapFilterState.showIgnored] is the one place the map deliberately differs. The node list
* segregates (`isIgnored == showIgnored`, so switching it on shows *only* ignored nodes); here it reads literally
* and adds them, because a map of nothing but ignored nodes is not a view anyone asked for.
*/
Tff7b72private Tff7b72fun Te6edf3NodeTb4b4b4.Td2a8ffpassesFiltersTb4b4b4(Te6edf3filterStateTb4b4b4: Te6edf3BaseMapViewModelTb4b4b4.Te6edf3MapFilterStateTb4b4b4, Te6edf3nowSecondsTb4b4b4: Tffa657LongTb4b4b4)Tb4b4b4: Tffa657Boolean Tb4b4b4{
Tff7b72val Te6edf3secondsSinceHeard Tff7b72= Te6edf3nowSeconds Tff7b72- Te6edf3lastHeard
Tff7b72val Te6edf3cutoff Tff7b72= Te6edf3filterStateTb4b4b4.Te6edf3lastHeardFilterTb4b4b4.Te6edf3seconds
Tff7b72return Tb4b4b4(Tff7b72!Te6edf3filterStateTb4b4b4.Te6edf3onlyFavorites Tff7b72|Tff7b72| Te6edf3isFavoriteTb4b4b4) Tff7b72&Tff7b72&
Tb4b4b4(Tff7b72!Te6edf3isIgnored Tff7b72|Tff7b72| Te6edf3filterStateTb4b4b4.Te6edf3showIgnoredTb4b4b4) Tff7b72&Tff7b72&
Te6edf3userTb4b4b4.Te6edf3role Tff7b72!in Te6edf3filterStateTb4b4b4.Te6edf3excludedRoles Tff7b72&Tff7b72&
Tb4b4b4(Tff7b72!Te6edf3filterStateTb4b4b4.Te6edf3onlyOnline Tff7b72|Tff7b72| Te6edf3secondsSinceHeard Tff7b72<Tff7b72= Te6edf3ONLINE_WINDOW_SECONDSTb4b4b4) Tff7b72&Tff7b72&
Tb4b4b4(Tff7b72!Te6edf3filterStateTb4b4b4.Te6edf3onlyDirect Tff7b72|Tff7b72| Te6edf3hopsAway Tff7b72=Tff7b72= T79c0ff0Tb4b4b4) Tff7b72&Tff7b72&
Tb4b4b4(Tff7b72!Te6edf3filterStateTb4b4b4.Te6edf3excludeMqtt Tff7b72|Tff7b72| Tff7b72!Te6edf3viaMqttTb4b4b4) Tff7b72&Tff7b72&
Tb4b4b4(Te6edf3filterStateTb4b4b4.Te6edf3includeUnknown Tff7b72|Tff7b72| Te6edf3userTb4b4b4.Te6edf3short_nameTb4b4b4.Te6edf3isNotEmptyTb4b4b4(Tb4b4b4)Tb4b4b4) Tff7b72&Tff7b72&
Tb4b4b4(Te6edf3cutoff Tff7b72=Tff7b72= Te6edf3LastHeardFilterTb4b4b4.Te6edf3AnyTb4b4b4.Te6edf3seconds Tff7b72|Tff7b72| Te6edf3secondsSinceHeard Tff7b72<Tff7b72= Te6edf3cutoffTb4b4b4)
Tb4b4b4}
Tb4b4b4}
T8b949e/**
* Resolves persisted role names back to roles, dropping any the current protobufs no longer define.
*
* Names rather than ordinals, and forgiving of names it does not know: a set written by a newer build (or a role
* removed from the protos) must not throw on the way back in.
*/
Tff7b72fun Td2a8ffdecodeExcludedRolesTb4b4b4(Te6edf3namesTb4b4b4: Te6edf3SetTff7b72<Tffa657StringTff7b72>Tb4b4b4)Tb4b4b4: Te6edf3SetTff7b72<Te6edf3ConfigTb4b4b4.Te6edf3DeviceConfigTb4b4b4.Te6edf3RoleTff7b72> Tff7b72=
Te6edf3namesTb4b4b4.Te6edf3mapNotNullToTb4b4b4(Te6edf3mutableSetOfTb4b4b4(Tb4b4b4)Tb4b4b4) Tb4b4b4{ Te6edf3name Tff7b72-Tff7b72> Te6edf3ConfigTb4b4b4.Te6edf3DeviceConfigTb4b4b4.Te6edf3RoleTb4b4b4.Te6edf3entriesTb4b4b4.Te6edf3firstOrNull Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3name Tff7b72=Tff7b72= Te6edf3name Tb4b4b4} Tb4b4b4}
Served by rngit 1.5.2 - Generated in 0.04s